package mydb;

import iBoxDB.LocalServer.DB;
import java.io.File;
import java.util.TreeMap;

public class MyDB {

    public static Object testLock = new Object();
    
    public static DB.AutoBox instance = null;

    public synchronized static void create(String path) {
        if (instance == null) {
            (new File(path)).mkdir();
            DB.root(path);
            DB server = new DB();
            server.getConfig().ensureTable("test", new TreeMap() {
                {
                    put("id", 0L);
                }
            });
            instance = server.open();
        }
    }

    public synchronized static void close() {
        if (instance != null) {
            instance.getDatabase().close();
            instance = null;
        }
    }
}
